package fr.upmc.cie;

import fr.upmc.cie.data.CategorieItem;
import fr.upmc.cie.data.DataManager;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;



public class CategorieCreate extends Activity{
	
	private CategorieCreate self = this;
	
	@Override
	public void onCreate(Bundle savedInstanceState){
		super.onCreate(savedInstanceState);
		setContentView(R.layout.category_create);
		
		final EditText categ_title = (EditText) this.findViewById(R.id.ajouter_flux_title);
		final Button btAjoutCateg = (Button) this.findViewById(R.id.ajouter_flux_bt);
		
		btAjoutCateg.setOnClickListener(new OnClickListener(){

			@Override
			public void onClick(View v) {
			CategorieItem newItem = new CategorieItem();
			newItem.setName(categ_title.getText().toString());
			DataManager.getCategorieManager(self).insertCategorie(newItem, self);
			
			Intent i = new Intent();
			setResult(2, i);
			finish();
			
			}
		});
		
		}
		 
}

